/**
 * Created with WebStorm.
 * @Author: panda
 * @Date: 2022-05-18 09:25
 * @Description: 腾讯云接口
 */
import {createRequestClient} from './axios/request';
import {APISchema} from "@/api/axios/type";
import localCache from "@/utils/localCache";
interface CosSchema extends APISchema {
  getCredential: {
    request: {};
    response: {
      code: number,
      data: {
        credentials: {
          sessionToken: string,
          tmpSecretId: string,
          tmpSecretKey: string
        },
        expiration: string,
        expiredTime: number,
        requestId: string,
        startTime: number
      },
      msg: string
    };
  };

}

export const cosApi = createRequestClient<CosSchema>({
  baseURL: process.env.NODE_ENV === 'development'
    ? process.env.VUE_APP_API_HOST + ''
    : '',
  apis: {
    getCredential: {
      path: '/credential',
      method: "GET",
      headers: {token: localCache.getCache("token")}
    }
  },
});
